{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "5bbb79a0",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# 导入模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "671c1c89",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from pyecharts.charts import *\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.globals import ThemeType\n",
    "from pyecharts.globals import SymbolType\n",
    "from pyecharts.commons.utils import JsCode\n",
    "from pyecharts.charts import Line,Bar,Page,Map"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1abbe6b5",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# 检查数据"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9a220cb7",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "## 结婚登记（万对）数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "225e7519",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>地区</th>\n",
       "      <th>2019年</th>\n",
       "      <th>2018年</th>\n",
       "      <th>2017年</th>\n",
       "      <th>2016年</th>\n",
       "      <th>2015年</th>\n",
       "      <th>2014年</th>\n",
       "      <th>2013年</th>\n",
       "      <th>2012年</th>\n",
       "      <th>2011年</th>\n",
       "      <th>2010年</th>\n",
       "      <th>2009年</th>\n",
       "      <th>2008年</th>\n",
       "      <th>2007年</th>\n",
       "      <th>2006年</th>\n",
       "      <th>2005年</th>\n",
       "      <th>2004年</th>\n",
       "      <th>2003年</th>\n",
       "      <th>2002年</th>\n",
       "      <th>2001年</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>北京市</td>\n",
       "      <td>12.90</td>\n",
       "      <td>13.78</td>\n",
       "      <td>15.15</td>\n",
       "      <td>16.62</td>\n",
       "      <td>16.60</td>\n",
       "      <td>17.00</td>\n",
       "      <td>16.37</td>\n",
       "      <td>17.41</td>\n",
       "      <td>17.32</td>\n",
       "      <td>13.8</td>\n",
       "      <td>18.18</td>\n",
       "      <td>14.75</td>\n",
       "      <td>11.79</td>\n",
       "      <td>17.1</td>\n",
       "      <td>9.7</td>\n",
       "      <td>12.64</td>\n",
       "      <td>9.4</td>\n",
       "      <td>7.6</td>\n",
       "      <td>7.94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>天津市</td>\n",
       "      <td>9.64</td>\n",
       "      <td>9.75</td>\n",
       "      <td>9.51</td>\n",
       "      <td>9.82</td>\n",
       "      <td>10.12</td>\n",
       "      <td>9.94</td>\n",
       "      <td>10.26</td>\n",
       "      <td>10.14</td>\n",
       "      <td>10.41</td>\n",
       "      <td>8.7</td>\n",
       "      <td>10.40</td>\n",
       "      <td>8.93</td>\n",
       "      <td>7.57</td>\n",
       "      <td>8.4</td>\n",
       "      <td>6.4</td>\n",
       "      <td>7.70</td>\n",
       "      <td>6.3</td>\n",
       "      <td>5.4</td>\n",
       "      <td>5.79</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>河北省</td>\n",
       "      <td>42.13</td>\n",
       "      <td>45.87</td>\n",
       "      <td>50.49</td>\n",
       "      <td>55.19</td>\n",
       "      <td>60.94</td>\n",
       "      <td>66.13</td>\n",
       "      <td>74.08</td>\n",
       "      <td>74.53</td>\n",
       "      <td>77.72</td>\n",
       "      <td>75.0</td>\n",
       "      <td>72.00</td>\n",
       "      <td>66.31</td>\n",
       "      <td>60.39</td>\n",
       "      <td>55.5</td>\n",
       "      <td>53.8</td>\n",
       "      <td>57.48</td>\n",
       "      <td>52.4</td>\n",
       "      <td>47.1</td>\n",
       "      <td>44.56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>山西省</td>\n",
       "      <td>25.50</td>\n",
       "      <td>27.85</td>\n",
       "      <td>28.77</td>\n",
       "      <td>30.01</td>\n",
       "      <td>34.68</td>\n",
       "      <td>35.07</td>\n",
       "      <td>38.40</td>\n",
       "      <td>36.28</td>\n",
       "      <td>33.96</td>\n",
       "      <td>36.1</td>\n",
       "      <td>34.36</td>\n",
       "      <td>28.74</td>\n",
       "      <td>23.85</td>\n",
       "      <td>20.2</td>\n",
       "      <td>19.0</td>\n",
       "      <td>16.15</td>\n",
       "      <td>14.5</td>\n",
       "      <td>15.4</td>\n",
       "      <td>14.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>内蒙古自治区</td>\n",
       "      <td>16.18</td>\n",
       "      <td>17.69</td>\n",
       "      <td>18.70</td>\n",
       "      <td>19.84</td>\n",
       "      <td>21.79</td>\n",
       "      <td>21.68</td>\n",
       "      <td>22.16</td>\n",
       "      <td>20.77</td>\n",
       "      <td>21.53</td>\n",
       "      <td>20.3</td>\n",
       "      <td>18.84</td>\n",
       "      <td>18.78</td>\n",
       "      <td>18.57</td>\n",
       "      <td>16.3</td>\n",
       "      <td>15.5</td>\n",
       "      <td>14.77</td>\n",
       "      <td>13.1</td>\n",
       "      <td>13.1</td>\n",
       "      <td>14.76</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       地区  2019年  2018年  2017年  2016年  2015年  2014年  2013年  2012年  2011年  \\\n",
       "0     北京市  12.90  13.78  15.15  16.62  16.60  17.00  16.37  17.41  17.32   \n",
       "1     天津市   9.64   9.75   9.51   9.82  10.12   9.94  10.26  10.14  10.41   \n",
       "2     河北省  42.13  45.87  50.49  55.19  60.94  66.13  74.08  74.53  77.72   \n",
       "3     山西省  25.50  27.85  28.77  30.01  34.68  35.07  38.40  36.28  33.96   \n",
       "4  内蒙古自治区  16.18  17.69  18.70  19.84  21.79  21.68  22.16  20.77  21.53   \n",
       "\n",
       "   2010年  2009年  2008年  2007年  2006年  2005年  2004年  2003年  2002年  2001年  \n",
       "0   13.8  18.18  14.75  11.79   17.1    9.7  12.64    9.4    7.6   7.94  \n",
       "1    8.7  10.40   8.93   7.57    8.4    6.4   7.70    6.3    5.4   5.79  \n",
       "2   75.0  72.00  66.31  60.39   55.5   53.8  57.48   52.4   47.1  44.56  \n",
       "3   36.1  34.36  28.74  23.85   20.2   19.0  16.15   14.5   15.4  14.62  \n",
       "4   20.3  18.84  18.78  18.57   16.3   15.5  14.77   13.1   13.1  14.76  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_marry = pd.read_excel('结婚登记(万对).xlsx')\n",
    "df_marry.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b6e91f53",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "## 离婚登记（万对）数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "bc3089b9",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>地区</th>\n",
       "      <th>2019年</th>\n",
       "      <th>2018年</th>\n",
       "      <th>2017年</th>\n",
       "      <th>2016年</th>\n",
       "      <th>2015年</th>\n",
       "      <th>2014年</th>\n",
       "      <th>2013年</th>\n",
       "      <th>2012年</th>\n",
       "      <th>2011年</th>\n",
       "      <th>2010年</th>\n",
       "      <th>2009年</th>\n",
       "      <th>2008年</th>\n",
       "      <th>2007年</th>\n",
       "      <th>2006年</th>\n",
       "      <th>2005年</th>\n",
       "      <th>2004年</th>\n",
       "      <th>2003年</th>\n",
       "      <th>2002年</th>\n",
       "      <th>2001年</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>北京市</td>\n",
       "      <td>8.38</td>\n",
       "      <td>7.41</td>\n",
       "      <td>8.06</td>\n",
       "      <td>10.58</td>\n",
       "      <td>8.22</td>\n",
       "      <td>6.56</td>\n",
       "      <td>6.46</td>\n",
       "      <td>4.86</td>\n",
       "      <td>4.35</td>\n",
       "      <td>4.4</td>\n",
       "      <td>4.13</td>\n",
       "      <td>3.76</td>\n",
       "      <td>3.66</td>\n",
       "      <td>3.6</td>\n",
       "      <td>3.4</td>\n",
       "      <td>3.3</td>\n",
       "      <td>3.1</td>\n",
       "      <td>2.8</td>\n",
       "      <td>2.77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>天津市</td>\n",
       "      <td>7.47</td>\n",
       "      <td>6.41</td>\n",
       "      <td>5.89</td>\n",
       "      <td>6.52</td>\n",
       "      <td>5.19</td>\n",
       "      <td>4.45</td>\n",
       "      <td>4.53</td>\n",
       "      <td>3.63</td>\n",
       "      <td>3.21</td>\n",
       "      <td>3.0</td>\n",
       "      <td>2.76</td>\n",
       "      <td>2.40</td>\n",
       "      <td>2.21</td>\n",
       "      <td>2.1</td>\n",
       "      <td>1.9</td>\n",
       "      <td>1.8</td>\n",
       "      <td>1.4</td>\n",
       "      <td>1.2</td>\n",
       "      <td>1.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>河北省</td>\n",
       "      <td>25.57</td>\n",
       "      <td>23.45</td>\n",
       "      <td>23.24</td>\n",
       "      <td>22.02</td>\n",
       "      <td>19.90</td>\n",
       "      <td>18.57</td>\n",
       "      <td>17.88</td>\n",
       "      <td>17.12</td>\n",
       "      <td>15.63</td>\n",
       "      <td>14.5</td>\n",
       "      <td>12.67</td>\n",
       "      <td>11.22</td>\n",
       "      <td>9.88</td>\n",
       "      <td>9.2</td>\n",
       "      <td>8.3</td>\n",
       "      <td>7.7</td>\n",
       "      <td>5.8</td>\n",
       "      <td>5.3</td>\n",
       "      <td>5.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>山西省</td>\n",
       "      <td>9.12</td>\n",
       "      <td>8.75</td>\n",
       "      <td>8.22</td>\n",
       "      <td>7.65</td>\n",
       "      <td>7.22</td>\n",
       "      <td>6.56</td>\n",
       "      <td>6.10</td>\n",
       "      <td>5.28</td>\n",
       "      <td>4.75</td>\n",
       "      <td>4.3</td>\n",
       "      <td>3.89</td>\n",
       "      <td>3.28</td>\n",
       "      <td>3.24</td>\n",
       "      <td>3.0</td>\n",
       "      <td>2.9</td>\n",
       "      <td>2.7</td>\n",
       "      <td>2.3</td>\n",
       "      <td>2.3</td>\n",
       "      <td>2.29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>内蒙古自治区</td>\n",
       "      <td>9.98</td>\n",
       "      <td>9.88</td>\n",
       "      <td>10.09</td>\n",
       "      <td>9.84</td>\n",
       "      <td>9.19</td>\n",
       "      <td>8.84</td>\n",
       "      <td>8.07</td>\n",
       "      <td>7.06</td>\n",
       "      <td>6.67</td>\n",
       "      <td>5.7</td>\n",
       "      <td>5.20</td>\n",
       "      <td>5.02</td>\n",
       "      <td>4.73</td>\n",
       "      <td>4.1</td>\n",
       "      <td>3.9</td>\n",
       "      <td>3.7</td>\n",
       "      <td>3.0</td>\n",
       "      <td>2.5</td>\n",
       "      <td>3.31</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       地区  2019年  2018年  2017年  2016年  2015年  2014年  2013年  2012年  2011年  \\\n",
       "0     北京市   8.38   7.41   8.06  10.58   8.22   6.56   6.46   4.86   4.35   \n",
       "1     天津市   7.47   6.41   5.89   6.52   5.19   4.45   4.53   3.63   3.21   \n",
       "2     河北省  25.57  23.45  23.24  22.02  19.90  18.57  17.88  17.12  15.63   \n",
       "3     山西省   9.12   8.75   8.22   7.65   7.22   6.56   6.10   5.28   4.75   \n",
       "4  内蒙古自治区   9.98   9.88  10.09   9.84   9.19   8.84   8.07   7.06   6.67   \n",
       "\n",
       "   2010年  2009年  2008年  2007年  2006年  2005年  2004年  2003年  2002年  2001年  \n",
       "0    4.4   4.13   3.76   3.66    3.6    3.4    3.3    3.1    2.8   2.77  \n",
       "1    3.0   2.76   2.40   2.21    2.1    1.9    1.8    1.4    1.2   1.31  \n",
       "2   14.5  12.67  11.22   9.88    9.2    8.3    7.7    5.8    5.3   5.16  \n",
       "3    4.3   3.89   3.28   3.24    3.0    2.9    2.7    2.3    2.3   2.29  \n",
       "4    5.7   5.20   5.02   4.73    4.1    3.9    3.7    3.0    2.5   3.31  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_divorce = pd.read_excel('离婚登记(万对).xlsx')\n",
    "df_divorce.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "039b2db9",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "## 检查数据完整度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9dad7856",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "地区       False\n",
       "2019年    False\n",
       "2018年    False\n",
       "2017年    False\n",
       "2016年    False\n",
       "2015年    False\n",
       "2014年    False\n",
       "2013年    False\n",
       "2012年    False\n",
       "2011年    False\n",
       "2010年    False\n",
       "2009年    False\n",
       "2008年    False\n",
       "2007年    False\n",
       "2006年    False\n",
       "2005年    False\n",
       "2004年    False\n",
       "2003年    False\n",
       "2002年    False\n",
       "2001年    False\n",
       "dtype: bool"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_marry.isnull().any()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "ce465c5e",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "地区       False\n",
       "2019年    False\n",
       "2018年    False\n",
       "2017年    False\n",
       "2016年    False\n",
       "2015年    False\n",
       "2014年    False\n",
       "2013年    False\n",
       "2012年    False\n",
       "2011年    False\n",
       "2010年    False\n",
       "2009年    False\n",
       "2008年    False\n",
       "2007年    False\n",
       "2006年    False\n",
       "2005年    False\n",
       "2004年    False\n",
       "2003年    False\n",
       "2002年    False\n",
       "2001年    False\n",
       "dtype: bool"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_divorce.isnull().any()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e5c07d9e",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# 新增列：结婚占比、离婚占比、离结率-2019"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "513274b6",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>地区</th>\n",
       "      <th>结婚</th>\n",
       "      <th>离婚</th>\n",
       "      <th>结婚占比</th>\n",
       "      <th>离婚占比</th>\n",
       "      <th>离结率</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>北京市</td>\n",
       "      <td>12.90</td>\n",
       "      <td>8.38</td>\n",
       "      <td>60.62</td>\n",
       "      <td>39.38</td>\n",
       "      <td>0.65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>天津市</td>\n",
       "      <td>9.64</td>\n",
       "      <td>7.47</td>\n",
       "      <td>56.34</td>\n",
       "      <td>43.66</td>\n",
       "      <td>0.77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>河北省</td>\n",
       "      <td>42.13</td>\n",
       "      <td>25.57</td>\n",
       "      <td>62.23</td>\n",
       "      <td>37.77</td>\n",
       "      <td>0.61</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>山西省</td>\n",
       "      <td>25.50</td>\n",
       "      <td>9.12</td>\n",
       "      <td>73.66</td>\n",
       "      <td>26.34</td>\n",
       "      <td>0.36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>内蒙古自治区</td>\n",
       "      <td>16.18</td>\n",
       "      <td>9.98</td>\n",
       "      <td>61.85</td>\n",
       "      <td>38.15</td>\n",
       "      <td>0.62</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       地区     结婚     离婚   结婚占比   离婚占比   离结率\n",
       "0     北京市  12.90   8.38  60.62  39.38  0.65\n",
       "1     天津市   9.64   7.47  56.34  43.66  0.77\n",
       "2     河北省  42.13  25.57  62.23  37.77  0.61\n",
       "3     山西省  25.50   9.12  73.66  26.34  0.36\n",
       "4  内蒙古自治区  16.18   9.98  61.85  38.15  0.62"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 2019年各地区离结率\n",
    "df_tmp = pd.DataFrame()\n",
    "df_tmp['地区'] = df_marry['地区']\n",
    "df_tmp['结婚'] = df_marry['2019年']\n",
    "df_tmp['离婚'] = df_divorce['2019年']\n",
    "df_tmp['结婚占比'] = round(df_marry['2019年']*100 /(df_marry['2019年'] + df_divorce['2019年']), 2)\n",
    "df_tmp['离婚占比'] = round(df_divorce['2019年']*100 /(df_marry['2019年'] + df_divorce['2019年']), 2)\n",
    "df_tmp['离结率'] = round(df_tmp['离婚占比'] /(df_tmp['结婚占比']), 2)\n",
    "df_tmp.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fd3fef2c",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# 可视化"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "90f95f70",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "## 2019年各地区结婚离婚占比"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "62c155c4",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'C:\\\\Users\\\\19108\\\\Desktop\\\\Internet _New Media\\\\交互式数据可视化\\\\final\\\\finaltest\\\\a.html'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 阴影样式\n",
    "itemstyle={\n",
    "    'normal': {\n",
    "        'shadowColor': 'rgba(0, 0, 0, .5)',  # 阴影颜色\n",
    "        'shadowBlur': 5,  # 阴影大小\n",
    "        'shadowOffsetY': 2,  # Y轴方向阴影偏移\n",
    "        'shadowOffsetX': 2,  # x轴方向阴影偏移\n",
    "        'borderColor': '#fff'\n",
    "    }\n",
    "}\n",
    "\n",
    "area = df_tmp['地区'].values.tolist()\n",
    "marry_count = df_tmp['结婚占比'].values.tolist()\n",
    "divorce_count = df_tmp['离婚占比'].values.tolist()\n",
    "\n",
    "b1 = (\n",
    "    Bar(\n",
    "        init_opts=opts.InitOpts(\n",
    "        width='800px', height='600px',\n",
    "        )\n",
    "    )\n",
    "    .add_xaxis(area)\n",
    "    .add_yaxis('结婚占比', marry_count, stack='stack1',itemstyle_opts=opts.ItemStyleOpts(color='#FF8066'))\n",
    "    .add_yaxis('离婚占比', divorce_count, stack='stack1',itemstyle_opts=opts.ItemStyleOpts(color='#B0A8B9'))\n",
    "    .set_series_opts(\n",
    "        label_opts=opts.LabelOpts(\n",
    "             is_show=True,\n",
    "             position='inside'\n",
    "        )\n",
    "    )\n",
    "    .set_global_opts(\n",
    "        legend_opts=opts.LegendOpts(\n",
    "            pos_right='10%',\n",
    "            pos_top='2%',\n",
    "            orient='horizontal',\n",
    "        ),\n",
    "        title_opts=opts.TitleOpts(\n",
    "            title='2019年各地区结婚离婚占比',\n",
    "            pos_top='2%'\n",
    "        ),\n",
    "    )\n",
    "    .reversal_axis()\n",
    ")\n",
    "b1.render('a.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3511ea03",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "## 2019离结率又高至低排序高亮图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "5f65ce0b",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style  type=\"text/css\" >\n",
       "#T_bdf69_row0_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 100.0%, transparent 100.0%);\n",
       "        }#T_bdf69_row1_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 98.3%, transparent 98.3%);\n",
       "        }#T_bdf69_row2_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 91.7%, transparent 91.7%);\n",
       "        }#T_bdf69_row3_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 86.7%, transparent 86.7%);\n",
       "        }#T_bdf69_row4_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 81.7%, transparent 81.7%);\n",
       "        }#T_bdf69_row5_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 80.0%, transparent 80.0%);\n",
       "        }#T_bdf69_row6_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 76.7%, transparent 76.7%);\n",
       "        }#T_bdf69_row7_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 75.0%, transparent 75.0%);\n",
       "        }#T_bdf69_row8_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 73.3%, transparent 73.3%);\n",
       "        }#T_bdf69_row9_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 68.3%, transparent 68.3%);\n",
       "        }#T_bdf69_row10_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 61.7%, transparent 61.7%);\n",
       "        }#T_bdf69_row11_col5,#T_bdf69_row12_col5,#T_bdf69_row13_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 60.0%, transparent 60.0%);\n",
       "        }#T_bdf69_row14_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 58.3%, transparent 58.3%);\n",
       "        }#T_bdf69_row15_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 55.0%, transparent 55.0%);\n",
       "        }#T_bdf69_row16_col5,#T_bdf69_row17_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 50.0%, transparent 50.0%);\n",
       "        }#T_bdf69_row18_col5,#T_bdf69_row19_col5,#T_bdf69_row20_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 48.3%, transparent 48.3%);\n",
       "        }#T_bdf69_row21_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 45.0%, transparent 45.0%);\n",
       "        }#T_bdf69_row22_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 43.3%, transparent 43.3%);\n",
       "        }#T_bdf69_row23_col5,#T_bdf69_row24_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 38.3%, transparent 38.3%);\n",
       "        }#T_bdf69_row25_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 33.3%, transparent 33.3%);\n",
       "        }#T_bdf69_row26_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 31.7%, transparent 31.7%);\n",
       "        }#T_bdf69_row27_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 26.7%, transparent 26.7%);\n",
       "        }#T_bdf69_row28_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 25.0%, transparent 25.0%);\n",
       "        }#T_bdf69_row29_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "            background:  linear-gradient(90deg,#CD3F2C 23.3%, transparent 23.3%);\n",
       "        }#T_bdf69_row30_col5{\n",
       "            width:  10em;\n",
       "             height:  80%;\n",
       "        }</style><table id=\"T_bdf69_\" ><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >地区</th>        <th class=\"col_heading level0 col1\" >结婚</th>        <th class=\"col_heading level0 col2\" >离婚</th>        <th class=\"col_heading level0 col3\" >结婚占比</th>        <th class=\"col_heading level0 col4\" >离婚占比</th>        <th class=\"col_heading level0 col5\" >离结率</th>    </tr></thead><tbody>\n",
       "                <tr>\n",
       "                        <th id=\"T_bdf69_level0_row0\" class=\"row_heading level0 row0\" >1</th>\n",
       "                        <td id=\"T_bdf69_row0_col0\" class=\"data row0 col0\" >天津市</td>\n",
       "                        <td id=\"T_bdf69_row0_col1\" class=\"data row0 col1\" >9.640000</td>\n",
       "                        <td id=\"T_bdf69_row0_col2\" class=\"data row0 col2\" >7.470000</td>\n",
       "                        <td id=\"T_bdf69_row0_col3\" class=\"data row0 col3\" >56.340000</td>\n",
       "                        <td id=\"T_bdf69_row0_col4\" class=\"data row0 col4\" >43.660000</td>\n",
       "                        <td id=\"T_bdf69_row0_col5\" class=\"data row0 col5\" >0.770000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row1\" class=\"row_heading level0 row1\" >7</th>\n",
       "                        <td id=\"T_bdf69_row1_col0\" class=\"data row1 col0\" >黑龙江省</td>\n",
       "                        <td id=\"T_bdf69_row1_col1\" class=\"data row1 col1\" >24.440000</td>\n",
       "                        <td id=\"T_bdf69_row1_col2\" class=\"data row1 col2\" >18.680000</td>\n",
       "                        <td id=\"T_bdf69_row1_col3\" class=\"data row1 col3\" >56.680000</td>\n",
       "                        <td id=\"T_bdf69_row1_col4\" class=\"data row1 col4\" >43.320000</td>\n",
       "                        <td id=\"T_bdf69_row1_col5\" class=\"data row1 col5\" >0.760000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row2\" class=\"row_heading level0 row2\" >6</th>\n",
       "                        <td id=\"T_bdf69_row2_col0\" class=\"data row2 col0\" >吉林省</td>\n",
       "                        <td id=\"T_bdf69_row2_col1\" class=\"data row2 col1\" >18.080000</td>\n",
       "                        <td id=\"T_bdf69_row2_col2\" class=\"data row2 col2\" >12.980000</td>\n",
       "                        <td id=\"T_bdf69_row2_col3\" class=\"data row2 col3\" >58.210000</td>\n",
       "                        <td id=\"T_bdf69_row2_col4\" class=\"data row2 col4\" >41.790000</td>\n",
       "                        <td id=\"T_bdf69_row2_col5\" class=\"data row2 col5\" >0.720000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row3\" class=\"row_heading level0 row3\" >5</th>\n",
       "                        <td id=\"T_bdf69_row3_col0\" class=\"data row3 col0\" >辽宁省</td>\n",
       "                        <td id=\"T_bdf69_row3_col1\" class=\"data row3 col1\" >25.560000</td>\n",
       "                        <td id=\"T_bdf69_row3_col2\" class=\"data row3 col2\" >17.680000</td>\n",
       "                        <td id=\"T_bdf69_row3_col3\" class=\"data row3 col3\" >59.110000</td>\n",
       "                        <td id=\"T_bdf69_row3_col4\" class=\"data row3 col4\" >40.890000</td>\n",
       "                        <td id=\"T_bdf69_row3_col5\" class=\"data row3 col5\" >0.690000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row4\" class=\"row_heading level0 row4\" >21</th>\n",
       "                        <td id=\"T_bdf69_row4_col0\" class=\"data row4 col0\" >重庆市</td>\n",
       "                        <td id=\"T_bdf69_row4_col1\" class=\"data row4 col1\" >23.830000</td>\n",
       "                        <td id=\"T_bdf69_row4_col2\" class=\"data row4 col2\" >15.620000</td>\n",
       "                        <td id=\"T_bdf69_row4_col3\" class=\"data row4 col3\" >60.410000</td>\n",
       "                        <td id=\"T_bdf69_row4_col4\" class=\"data row4 col4\" >39.590000</td>\n",
       "                        <td id=\"T_bdf69_row4_col5\" class=\"data row4 col5\" >0.660000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row5\" class=\"row_heading level0 row5\" >0</th>\n",
       "                        <td id=\"T_bdf69_row5_col0\" class=\"data row5 col0\" >北京市</td>\n",
       "                        <td id=\"T_bdf69_row5_col1\" class=\"data row5 col1\" >12.900000</td>\n",
       "                        <td id=\"T_bdf69_row5_col2\" class=\"data row5 col2\" >8.380000</td>\n",
       "                        <td id=\"T_bdf69_row5_col3\" class=\"data row5 col3\" >60.620000</td>\n",
       "                        <td id=\"T_bdf69_row5_col4\" class=\"data row5 col4\" >39.380000</td>\n",
       "                        <td id=\"T_bdf69_row5_col5\" class=\"data row5 col5\" >0.650000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row6\" class=\"row_heading level0 row6\" >8</th>\n",
       "                        <td id=\"T_bdf69_row6_col0\" class=\"data row6 col0\" >上海市</td>\n",
       "                        <td id=\"T_bdf69_row6_col1\" class=\"data row6 col1\" >9.870000</td>\n",
       "                        <td id=\"T_bdf69_row6_col2\" class=\"data row6 col2\" >6.170000</td>\n",
       "                        <td id=\"T_bdf69_row6_col3\" class=\"data row6 col3\" >61.530000</td>\n",
       "                        <td id=\"T_bdf69_row6_col4\" class=\"data row6 col4\" >38.470000</td>\n",
       "                        <td id=\"T_bdf69_row6_col5\" class=\"data row6 col5\" >0.630000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row7\" class=\"row_heading level0 row7\" >4</th>\n",
       "                        <td id=\"T_bdf69_row7_col0\" class=\"data row7 col0\" >内蒙古自治区</td>\n",
       "                        <td id=\"T_bdf69_row7_col1\" class=\"data row7 col1\" >16.180000</td>\n",
       "                        <td id=\"T_bdf69_row7_col2\" class=\"data row7 col2\" >9.980000</td>\n",
       "                        <td id=\"T_bdf69_row7_col3\" class=\"data row7 col3\" >61.850000</td>\n",
       "                        <td id=\"T_bdf69_row7_col4\" class=\"data row7 col4\" >38.150000</td>\n",
       "                        <td id=\"T_bdf69_row7_col5\" class=\"data row7 col5\" >0.620000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row8\" class=\"row_heading level0 row8\" >2</th>\n",
       "                        <td id=\"T_bdf69_row8_col0\" class=\"data row8 col0\" >河北省</td>\n",
       "                        <td id=\"T_bdf69_row8_col1\" class=\"data row8 col1\" >42.130000</td>\n",
       "                        <td id=\"T_bdf69_row8_col2\" class=\"data row8 col2\" >25.570000</td>\n",
       "                        <td id=\"T_bdf69_row8_col3\" class=\"data row8 col3\" >62.230000</td>\n",
       "                        <td id=\"T_bdf69_row8_col4\" class=\"data row8 col4\" >37.770000</td>\n",
       "                        <td id=\"T_bdf69_row8_col5\" class=\"data row8 col5\" >0.610000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row9\" class=\"row_heading level0 row9\" >17</th>\n",
       "                        <td id=\"T_bdf69_row9_col0\" class=\"data row9 col0\" >湖南省</td>\n",
       "                        <td id=\"T_bdf69_row9_col1\" class=\"data row9 col1\" >38.030000</td>\n",
       "                        <td id=\"T_bdf69_row9_col2\" class=\"data row9 col2\" >22.040000</td>\n",
       "                        <td id=\"T_bdf69_row9_col3\" class=\"data row9 col3\" >63.310000</td>\n",
       "                        <td id=\"T_bdf69_row9_col4\" class=\"data row9 col4\" >36.690000</td>\n",
       "                        <td id=\"T_bdf69_row9_col5\" class=\"data row9 col5\" >0.580000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row10\" class=\"row_heading level0 row10\" >16</th>\n",
       "                        <td id=\"T_bdf69_row10_col0\" class=\"data row10 col0\" >湖北省</td>\n",
       "                        <td id=\"T_bdf69_row10_col1\" class=\"data row10 col1\" >38.930000</td>\n",
       "                        <td id=\"T_bdf69_row10_col2\" class=\"data row10 col2\" >21.210000</td>\n",
       "                        <td id=\"T_bdf69_row10_col3\" class=\"data row10 col3\" >64.730000</td>\n",
       "                        <td id=\"T_bdf69_row10_col4\" class=\"data row10 col4\" >35.270000</td>\n",
       "                        <td id=\"T_bdf69_row10_col5\" class=\"data row10 col5\" >0.540000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row11\" class=\"row_heading level0 row11\" >9</th>\n",
       "                        <td id=\"T_bdf69_row11_col0\" class=\"data row11 col0\" >江苏省</td>\n",
       "                        <td id=\"T_bdf69_row11_col1\" class=\"data row11 col1\" >56.940000</td>\n",
       "                        <td id=\"T_bdf69_row11_col2\" class=\"data row11 col2\" >29.950000</td>\n",
       "                        <td id=\"T_bdf69_row11_col3\" class=\"data row11 col3\" >65.530000</td>\n",
       "                        <td id=\"T_bdf69_row11_col4\" class=\"data row11 col4\" >34.470000</td>\n",
       "                        <td id=\"T_bdf69_row11_col5\" class=\"data row11 col5\" >0.530000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row12\" class=\"row_heading level0 row12\" >10</th>\n",
       "                        <td id=\"T_bdf69_row12_col0\" class=\"data row12 col0\" >浙江省</td>\n",
       "                        <td id=\"T_bdf69_row12_col1\" class=\"data row12 col1\" >29.360000</td>\n",
       "                        <td id=\"T_bdf69_row12_col2\" class=\"data row12 col2\" >15.440000</td>\n",
       "                        <td id=\"T_bdf69_row12_col3\" class=\"data row12 col3\" >65.540000</td>\n",
       "                        <td id=\"T_bdf69_row12_col4\" class=\"data row12 col4\" >34.460000</td>\n",
       "                        <td id=\"T_bdf69_row12_col5\" class=\"data row12 col5\" >0.530000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row13\" class=\"row_heading level0 row13\" >14</th>\n",
       "                        <td id=\"T_bdf69_row13_col0\" class=\"data row13 col0\" >山东省</td>\n",
       "                        <td id=\"T_bdf69_row13_col1\" class=\"data row13 col1\" >53.300000</td>\n",
       "                        <td id=\"T_bdf69_row13_col2\" class=\"data row13 col2\" >28.460000</td>\n",
       "                        <td id=\"T_bdf69_row13_col3\" class=\"data row13 col3\" >65.190000</td>\n",
       "                        <td id=\"T_bdf69_row13_col4\" class=\"data row13 col4\" >34.810000</td>\n",
       "                        <td id=\"T_bdf69_row13_col5\" class=\"data row13 col5\" >0.530000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row14\" class=\"row_heading level0 row14\" >22</th>\n",
       "                        <td id=\"T_bdf69_row14_col0\" class=\"data row14 col0\" >四川省</td>\n",
       "                        <td id=\"T_bdf69_row14_col1\" class=\"data row14 col1\" >61.320000</td>\n",
       "                        <td id=\"T_bdf69_row14_col2\" class=\"data row14 col2\" >31.940000</td>\n",
       "                        <td id=\"T_bdf69_row14_col3\" class=\"data row14 col3\" >65.750000</td>\n",
       "                        <td id=\"T_bdf69_row14_col4\" class=\"data row14 col4\" >34.250000</td>\n",
       "                        <td id=\"T_bdf69_row14_col5\" class=\"data row14 col5\" >0.520000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row15\" class=\"row_heading level0 row15\" >26</th>\n",
       "                        <td id=\"T_bdf69_row15_col0\" class=\"data row15 col0\" >陕西省</td>\n",
       "                        <td id=\"T_bdf69_row15_col1\" class=\"data row15 col1\" >27.190000</td>\n",
       "                        <td id=\"T_bdf69_row15_col2\" class=\"data row15 col2\" >13.670000</td>\n",
       "                        <td id=\"T_bdf69_row15_col3\" class=\"data row15 col3\" >66.540000</td>\n",
       "                        <td id=\"T_bdf69_row15_col4\" class=\"data row15 col4\" >33.460000</td>\n",
       "                        <td id=\"T_bdf69_row15_col5\" class=\"data row15 col5\" >0.500000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row16\" class=\"row_heading level0 row16\" >15</th>\n",
       "                        <td id=\"T_bdf69_row16_col0\" class=\"data row16 col0\" >河南省</td>\n",
       "                        <td id=\"T_bdf69_row16_col1\" class=\"data row16 col1\" >76.450000</td>\n",
       "                        <td id=\"T_bdf69_row16_col2\" class=\"data row16 col2\" >35.650000</td>\n",
       "                        <td id=\"T_bdf69_row16_col3\" class=\"data row16 col3\" >68.200000</td>\n",
       "                        <td id=\"T_bdf69_row16_col4\" class=\"data row16 col4\" >31.800000</td>\n",
       "                        <td id=\"T_bdf69_row16_col5\" class=\"data row16 col5\" >0.470000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row17\" class=\"row_heading level0 row17\" >12</th>\n",
       "                        <td id=\"T_bdf69_row17_col0\" class=\"data row17 col0\" >福建省</td>\n",
       "                        <td id=\"T_bdf69_row17_col1\" class=\"data row17 col1\" >24.030000</td>\n",
       "                        <td id=\"T_bdf69_row17_col2\" class=\"data row17 col2\" >11.240000</td>\n",
       "                        <td id=\"T_bdf69_row17_col3\" class=\"data row17 col3\" >68.130000</td>\n",
       "                        <td id=\"T_bdf69_row17_col4\" class=\"data row17 col4\" >31.870000</td>\n",
       "                        <td id=\"T_bdf69_row17_col5\" class=\"data row17 col5\" >0.470000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row18\" class=\"row_heading level0 row18\" >13</th>\n",
       "                        <td id=\"T_bdf69_row18_col0\" class=\"data row18 col0\" >江西省</td>\n",
       "                        <td id=\"T_bdf69_row18_col1\" class=\"data row18 col1\" >28.870000</td>\n",
       "                        <td id=\"T_bdf69_row18_col2\" class=\"data row18 col2\" >13.190000</td>\n",
       "                        <td id=\"T_bdf69_row18_col3\" class=\"data row18 col3\" >68.640000</td>\n",
       "                        <td id=\"T_bdf69_row18_col4\" class=\"data row18 col4\" >31.360000</td>\n",
       "                        <td id=\"T_bdf69_row18_col5\" class=\"data row18 col5\" >0.460000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row19\" class=\"row_heading level0 row19\" >11</th>\n",
       "                        <td id=\"T_bdf69_row19_col0\" class=\"data row19 col0\" >安徽省</td>\n",
       "                        <td id=\"T_bdf69_row19_col1\" class=\"data row19 col1\" >54.160000</td>\n",
       "                        <td id=\"T_bdf69_row19_col2\" class=\"data row19 col2\" >25.010000</td>\n",
       "                        <td id=\"T_bdf69_row19_col3\" class=\"data row19 col3\" >68.410000</td>\n",
       "                        <td id=\"T_bdf69_row19_col4\" class=\"data row19 col4\" >31.590000</td>\n",
       "                        <td id=\"T_bdf69_row19_col5\" class=\"data row19 col5\" >0.460000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row20\" class=\"row_heading level0 row20\" >23</th>\n",
       "                        <td id=\"T_bdf69_row20_col0\" class=\"data row20 col0\" >贵州省</td>\n",
       "                        <td id=\"T_bdf69_row20_col1\" class=\"data row20 col1\" >36.240000</td>\n",
       "                        <td id=\"T_bdf69_row20_col2\" class=\"data row20 col2\" >16.610000</td>\n",
       "                        <td id=\"T_bdf69_row20_col3\" class=\"data row20 col3\" >68.570000</td>\n",
       "                        <td id=\"T_bdf69_row20_col4\" class=\"data row20 col4\" >31.430000</td>\n",
       "                        <td id=\"T_bdf69_row20_col5\" class=\"data row20 col5\" >0.460000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row21\" class=\"row_heading level0 row21\" >30</th>\n",
       "                        <td id=\"T_bdf69_row21_col0\" class=\"data row21 col0\" >新疆维吾尔自治区</td>\n",
       "                        <td id=\"T_bdf69_row21_col1\" class=\"data row21 col1\" >16.590000</td>\n",
       "                        <td id=\"T_bdf69_row21_col2\" class=\"data row21 col2\" >7.310000</td>\n",
       "                        <td id=\"T_bdf69_row21_col3\" class=\"data row21 col3\" >69.410000</td>\n",
       "                        <td id=\"T_bdf69_row21_col4\" class=\"data row21 col4\" >30.590000</td>\n",
       "                        <td id=\"T_bdf69_row21_col5\" class=\"data row21 col5\" >0.440000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row22\" class=\"row_heading level0 row22\" >19</th>\n",
       "                        <td id=\"T_bdf69_row22_col0\" class=\"data row22 col0\" >广西壮族自治区</td>\n",
       "                        <td id=\"T_bdf69_row22_col1\" class=\"data row22 col1\" >33.030000</td>\n",
       "                        <td id=\"T_bdf69_row22_col2\" class=\"data row22 col2\" >14.270000</td>\n",
       "                        <td id=\"T_bdf69_row22_col3\" class=\"data row22 col3\" >69.830000</td>\n",
       "                        <td id=\"T_bdf69_row22_col4\" class=\"data row22 col4\" >30.170000</td>\n",
       "                        <td id=\"T_bdf69_row22_col5\" class=\"data row22 col5\" >0.430000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row23\" class=\"row_heading level0 row23\" >24</th>\n",
       "                        <td id=\"T_bdf69_row23_col0\" class=\"data row23 col0\" >云南省</td>\n",
       "                        <td id=\"T_bdf69_row23_col1\" class=\"data row23 col1\" >35.920000</td>\n",
       "                        <td id=\"T_bdf69_row23_col2\" class=\"data row23 col2\" >14.450000</td>\n",
       "                        <td id=\"T_bdf69_row23_col3\" class=\"data row23 col3\" >71.310000</td>\n",
       "                        <td id=\"T_bdf69_row23_col4\" class=\"data row23 col4\" >28.690000</td>\n",
       "                        <td id=\"T_bdf69_row23_col5\" class=\"data row23 col5\" >0.400000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row24\" class=\"row_heading level0 row24\" >29</th>\n",
       "                        <td id=\"T_bdf69_row24_col0\" class=\"data row24 col0\" >宁夏回族自治区</td>\n",
       "                        <td id=\"T_bdf69_row24_col1\" class=\"data row24 col1\" >6.090000</td>\n",
       "                        <td id=\"T_bdf69_row24_col2\" class=\"data row24 col2\" >2.440000</td>\n",
       "                        <td id=\"T_bdf69_row24_col3\" class=\"data row24 col3\" >71.400000</td>\n",
       "                        <td id=\"T_bdf69_row24_col4\" class=\"data row24 col4\" >28.600000</td>\n",
       "                        <td id=\"T_bdf69_row24_col5\" class=\"data row24 col5\" >0.400000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row25\" class=\"row_heading level0 row25\" >18</th>\n",
       "                        <td id=\"T_bdf69_row25_col0\" class=\"data row25 col0\" >广东省</td>\n",
       "                        <td id=\"T_bdf69_row25_col1\" class=\"data row25 col1\" >67.450000</td>\n",
       "                        <td id=\"T_bdf69_row25_col2\" class=\"data row25 col2\" >24.810000</td>\n",
       "                        <td id=\"T_bdf69_row25_col3\" class=\"data row25 col3\" >73.110000</td>\n",
       "                        <td id=\"T_bdf69_row25_col4\" class=\"data row25 col4\" >26.890000</td>\n",
       "                        <td id=\"T_bdf69_row25_col5\" class=\"data row25 col5\" >0.370000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row26\" class=\"row_heading level0 row26\" >3</th>\n",
       "                        <td id=\"T_bdf69_row26_col0\" class=\"data row26 col0\" >山西省</td>\n",
       "                        <td id=\"T_bdf69_row26_col1\" class=\"data row26 col1\" >25.500000</td>\n",
       "                        <td id=\"T_bdf69_row26_col2\" class=\"data row26 col2\" >9.120000</td>\n",
       "                        <td id=\"T_bdf69_row26_col3\" class=\"data row26 col3\" >73.660000</td>\n",
       "                        <td id=\"T_bdf69_row26_col4\" class=\"data row26 col4\" >26.340000</td>\n",
       "                        <td id=\"T_bdf69_row26_col5\" class=\"data row26 col5\" >0.360000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row27\" class=\"row_heading level0 row27\" >20</th>\n",
       "                        <td id=\"T_bdf69_row27_col0\" class=\"data row27 col0\" >海南省</td>\n",
       "                        <td id=\"T_bdf69_row27_col1\" class=\"data row27 col1\" >6.560000</td>\n",
       "                        <td id=\"T_bdf69_row27_col2\" class=\"data row27 col2\" >2.150000</td>\n",
       "                        <td id=\"T_bdf69_row27_col3\" class=\"data row27 col3\" >75.320000</td>\n",
       "                        <td id=\"T_bdf69_row27_col4\" class=\"data row27 col4\" >24.680000</td>\n",
       "                        <td id=\"T_bdf69_row27_col5\" class=\"data row27 col5\" >0.330000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row28\" class=\"row_heading level0 row28\" >28</th>\n",
       "                        <td id=\"T_bdf69_row28_col0\" class=\"data row28 col0\" >青海省</td>\n",
       "                        <td id=\"T_bdf69_row28_col1\" class=\"data row28 col1\" >5.770000</td>\n",
       "                        <td id=\"T_bdf69_row28_col2\" class=\"data row28 col2\" >1.850000</td>\n",
       "                        <td id=\"T_bdf69_row28_col3\" class=\"data row28 col3\" >75.720000</td>\n",
       "                        <td id=\"T_bdf69_row28_col4\" class=\"data row28 col4\" >24.280000</td>\n",
       "                        <td id=\"T_bdf69_row28_col5\" class=\"data row28 col5\" >0.320000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row29\" class=\"row_heading level0 row29\" >27</th>\n",
       "                        <td id=\"T_bdf69_row29_col0\" class=\"data row29 col0\" >甘肃省</td>\n",
       "                        <td id=\"T_bdf69_row29_col1\" class=\"data row29 col1\" >19.850000</td>\n",
       "                        <td id=\"T_bdf69_row29_col2\" class=\"data row29 col2\" >6.220000</td>\n",
       "                        <td id=\"T_bdf69_row29_col3\" class=\"data row29 col3\" >76.140000</td>\n",
       "                        <td id=\"T_bdf69_row29_col4\" class=\"data row29 col4\" >23.860000</td>\n",
       "                        <td id=\"T_bdf69_row29_col5\" class=\"data row29 col5\" >0.310000</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_bdf69_level0_row30\" class=\"row_heading level0 row30\" >25</th>\n",
       "                        <td id=\"T_bdf69_row30_col0\" class=\"data row30 col0\" >西藏自治区</td>\n",
       "                        <td id=\"T_bdf69_row30_col1\" class=\"data row30 col1\" >3.120000</td>\n",
       "                        <td id=\"T_bdf69_row30_col2\" class=\"data row30 col2\" >0.530000</td>\n",
       "                        <td id=\"T_bdf69_row30_col3\" class=\"data row30 col3\" >85.480000</td>\n",
       "                        <td id=\"T_bdf69_row30_col4\" class=\"data row30 col4\" >14.520000</td>\n",
       "                        <td id=\"T_bdf69_row30_col5\" class=\"data row30 col5\" >0.170000</td>\n",
       "            </tr>\n",
       "    </tbody></table>"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x1c49cbd6748>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_tmp = df_tmp.sort_values('离结率', ascending=False)\n",
    "df_tmp.style.bar(subset=['离结率'],color='#CD3F2C')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6df334fa",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "## 全国离结率TOP16渐变柱状图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "7138bb88",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'C:\\\\Users\\\\19108\\\\Desktop\\\\Internet _New Media\\\\交互式数据可视化\\\\final\\\\finaltest\\\\b.html'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sort_info = df_tmp.sort_values('离结率', ascending=True)\n",
    "b1 = (\n",
    "    Bar(init_opts=opts.InitOpts(\n",
    "        width='800px', height='600px',))\n",
    "    .add_xaxis(list(sort_info['地区'])[-16:])\n",
    "    .add_yaxis('', sort_info['离结率'].values.tolist()[-16:],\n",
    "               category_gap='30%',\n",
    "               itemstyle_opts={\n",
    "               'normal': {\n",
    "                   'shadowColor': 'rgba(0, 0, 0, .5)',  # 阴影颜色\n",
    "                   'shadowBlur': 5,  # 阴影大小\n",
    "                   'shadowOffsetY': 2,  # Y轴方向阴影偏移\n",
    "                   'shadowOffsetX': 2,  # x轴方向阴影偏移\n",
    "                   'borderColor': '#fff'\n",
    "                   }\n",
    "               }\n",
    "              )\n",
    "    .reversal_axis()\n",
    "    .set_global_opts(\n",
    "        xaxis_opts=opts.AxisOpts(is_show=False),    \n",
    "        yaxis_opts=opts.AxisOpts(is_show=False,\n",
    "            axisline_opts=opts.AxisLineOpts(is_show=False),\n",
    "            axistick_opts=opts.AxisTickOpts(is_show=False)\n",
    "        ),\n",
    "        title_opts=opts.TitleOpts(\n",
    "            title='全国离结率 TOP16',\n",
    "            pos_left='9%',\n",
    "            pos_top='4%',\n",
    "            title_textstyle_opts=opts.TextStyleOpts(\n",
    "                color='#ed1941', font_size=16)\n",
    "        ),\n",
    "        visualmap_opts=opts.VisualMapOpts(\n",
    "            is_show=False,\n",
    "            max_=15,\n",
    "            series_index=0,\n",
    "        ),\n",
    "     )\n",
    "    .set_series_opts(\n",
    "        itemstyle_opts={\n",
    "            \"normal\": {\n",
    "                \"color\": JsCode(\n",
    "                    \"\"\"new echarts.graphic.LinearGradient(0, 0, 0, 1, [{\n",
    "                offset: 0,\n",
    "                color: '#ed1941'\n",
    "            }, {\n",
    "                offset: 1,\n",
    "                color: '#009ad6'\n",
    "            }], false)\"\"\"\n",
    "                ),\n",
    "                \"barBorderRadius\": [30, 30, 30, 30],\n",
    "                \"shadowColor\": \"rgb(0, 160, 221)\",\n",
    "            }\n",
    "        },\n",
    "        label_opts=opts.LabelOpts(position=\"insideLeft\",\n",
    "                                              font_size=10,\n",
    "                                              vertical_align='middle',\n",
    "                                              horizontal_align='left',\n",
    "                                              font_weight='bold',\n",
    "                                              formatter='{b}: {c}'))\n",
    ")\n",
    "\n",
    "b1.render('b.html')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "25cfadcf",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "全国共有15个省市地区离结率超过50%，这已经是相当高了\n"
     ]
    }
   ],
   "source": [
    "print('全国共有{}个省市地区离结率超过50%，这已经是相当高了'.format(len(df_tmp[df_tmp['离结率'] > 0.5])))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "dc77a2c9",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1        天津市\n",
       "7       黑龙江省\n",
       "6        吉林省\n",
       "5        辽宁省\n",
       "21       重庆市\n",
       "0        北京市\n",
       "8        上海市\n",
       "4     内蒙古自治区\n",
       "2        河北省\n",
       "17       湖南省\n",
       "16       湖北省\n",
       "9        江苏省\n",
       "10       浙江省\n",
       "14       山东省\n",
       "22       四川省\n",
       "Name: 地区, dtype: object"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_tmp[df_tmp['离结率'] > 0.5]['地区']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3e8570bb",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "## 广东历年结婚/离婚登记数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "601a6cdd",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'C:\\\\Users\\\\19108\\\\Desktop\\\\Internet _New Media\\\\交互式数据可视化\\\\final\\\\finaltest\\\\c.html'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 线性渐变\n",
    "color_js0 = \"\"\"new echarts.graphic.LinearGradient(0, 1, 0, 0,\n",
    "    [{offset: 0, color: '#FFFFFF'}, {offset: 1, color: '#ed1941'}], false)\"\"\"\n",
    "\n",
    "color_js1 = \"\"\"new echarts.graphic.LinearGradient(0, 1, 0, 0,\n",
    "    [{offset: 0, color: '#FFFFFF'}, {offset: 1, color: '#009ad6'}], false)\"\"\"\n",
    "\n",
    "\n",
    "city = '广东省'\n",
    "b2 = (\n",
    "    Bar()\n",
    "    .add_xaxis(df_divorce.columns[1:].values.tolist())\n",
    "    .add_yaxis(\n",
    "        series_name=\"结婚登记\",\n",
    "        y_axis=df_marry[df_marry['地区']==city].values[0][1:].tolist(),\n",
    "        markpoint_opts=opts.MarkPointOpts(\n",
    "            data=[\n",
    "                opts.MarkPointItem(type_=\"max\", name=\"最大值\"),\n",
    "                opts.MarkPointItem(type_=\"min\", name=\"最小值\"),\n",
    "            ]\n",
    "        ),\n",
    "        itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_js0))\n",
    "    )\n",
    "    .add_yaxis(\n",
    "        series_name=\"离婚登记\",\n",
    "        y_axis=df_divorce[df_divorce['地区']=='广东省'].values[0][1:].tolist(),\n",
    "        markpoint_opts=opts.MarkPointOpts(\n",
    "            data=[\n",
    "                opts.MarkPointItem(type_=\"max\", name=\"最大值\"),\n",
    "                opts.MarkPointItem(type_=\"min\", name=\"最小值\"),\n",
    "            ]\n",
    "        ),\n",
    "        itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_js1))\n",
    "    )\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(title=\"\"),\n",
    "        tooltip_opts=opts.TooltipOpts(trigger=\"axis\"),\n",
    "        xaxis_opts=opts.AxisOpts(name=\"年份\",type_=\"category\", \n",
    "                                 boundary_gap=True,\n",
    "                                 axisline_opts=opts.AxisLineOpts(is_show=True,\n",
    "                                                                 linestyle_opts=opts.LineStyleOpts(width=4, color='#DB7093')),\n",
    "                                 axislabel_opts=opts.LabelOpts(rotate=45)),\n",
    "        yaxis_opts=opts.AxisOpts(\n",
    "                axislabel_opts=opts.LabelOpts(formatter=\"{value} /万对\"),\n",
    "                name=f'{city}历年结婚/离婚登记',            \n",
    "                is_scale=True,\n",
    "                name_textstyle_opts=opts.TextStyleOpts(font_size=15,font_weight='bold',color='#FF1493'),\n",
    "                splitline_opts=opts.SplitLineOpts(is_show=True, \n",
    "                                                  linestyle_opts=opts.LineStyleOpts(type_='dashed')),\n",
    "                axisline_opts=opts.AxisLineOpts(is_show=False,\n",
    "                                        linestyle_opts=opts.LineStyleOpts(width=2, color='#DB7093'))\n",
    "            ),\n",
    "        legend_opts=opts.LegendOpts(is_show=True, pos_top='2%', legend_icon='roundRect'),\n",
    "    )\n",
    ")\n",
    "b2.render('c.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3e4eed81",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "由图我们可以看出广东的离婚率几乎是逐年稳步提升，结婚率近五年来逐年下降"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3a8d1679",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "## 2019年各地区离结率数据热力图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "e6266a12",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'china':'https://assets.pyecharts.org/assets/maps/china'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"2eed60316aa9458db751deebf883c521\" style=\"width:800px; height:600px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'china'], function(echarts) {\n",
       "                var chart_2eed60316aa9458db751deebf883c521 = echarts.init(\n",
       "                    document.getElementById('2eed60316aa9458db751deebf883c521'), 'light', {renderer: 'canvas'});\n",
       "                var option_2eed60316aa9458db751deebf883c521 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"map\",\n",
       "            \"name\": \"\\u79bb\\u5a5a/\\u7ed3\\u5a5a\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"mapType\": \"china\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u5929\\u6d25\",\n",
       "                    \"value\": 0.77\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9ed1\\u9f99\\u6c5f\",\n",
       "                    \"value\": 0.76\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5409\\u6797\",\n",
       "                    \"value\": 0.72\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8fbd\\u5b81\",\n",
       "                    \"value\": 0.69\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u91cd\\u5e86\",\n",
       "                    \"value\": 0.66\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5317\\u4eac\",\n",
       "                    \"value\": 0.65\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e0a\\u6d77\",\n",
       "                    \"value\": 0.63\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5185\\u8499\\u53e4\",\n",
       "                    \"value\": 0.62\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5317\",\n",
       "                    \"value\": 0.61\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5357\",\n",
       "                    \"value\": 0.58\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5317\",\n",
       "                    \"value\": 0.54\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u82cf\",\n",
       "                    \"value\": 0.53\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d59\\u6c5f\",\n",
       "                    \"value\": 0.53\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u4e1c\",\n",
       "                    \"value\": 0.53\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u56db\\u5ddd\",\n",
       "                    \"value\": 0.52\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9655\\u897f\",\n",
       "                    \"value\": 0.5\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5357\",\n",
       "                    \"value\": 0.47\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u798f\\u5efa\",\n",
       "                    \"value\": 0.47\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u897f\",\n",
       "                    \"value\": 0.46\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b89\\u5fbd\",\n",
       "                    \"value\": 0.46\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8d35\\u5dde\",\n",
       "                    \"value\": 0.46\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65b0\\u7586\",\n",
       "                    \"value\": 0.44\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u897f\",\n",
       "                    \"value\": 0.43\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e91\\u5357\",\n",
       "                    \"value\": 0.4\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b81\\u590f\",\n",
       "                    \"value\": 0.4\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u4e1c\",\n",
       "                    \"value\": 0.37\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u897f\",\n",
       "                    \"value\": 0.36\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d77\\u5357\",\n",
       "                    \"value\": 0.33\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9752\\u6d77\",\n",
       "                    \"value\": 0.32\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7518\\u8083\",\n",
       "                    \"value\": 0.31\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u897f\\u85cf\",\n",
       "                    \"value\": 0.17\n",
       "                }\n",
       "            ],\n",
       "            \"roam\": true,\n",
       "            \"aspectScale\": 0.75,\n",
       "            \"nameProperty\": \"name\",\n",
       "            \"selectedMode\": false,\n",
       "            \"zoom\": 1,\n",
       "            \"mapValueCalculation\": \"sum\",\n",
       "            \"showLegendSymbol\": false,\n",
       "            \"itemStyle\": {\n",
       "                \"normal\": {\n",
       "                    \"shadowColor\": \"rgba(0, 0, 0, .5)\",\n",
       "                    \"shadowBlur\": 5,\n",
       "                    \"shadowOffsetY\": 0,\n",
       "                    \"shadowOffsetX\": 0,\n",
       "                    \"borderColor\": \"#fff\"\n",
       "                }\n",
       "            },\n",
       "            \"emphasis\": {}\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u79bb\\u5a5a/\\u7ed3\\u5a5a\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u79bb\\u5a5a/\\u7ed3\\u5a5a\": true\n",
       "            },\n",
       "            \"show\": false,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"formatter\": \"{b}:{c}\",\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": {\n",
       "        \"text\": \"2019\\u5e74\\u5404\\u5730\\u533a\\u79bb\\u7ed3\\u7387\",\n",
       "        \"left\": \"center\",\n",
       "        \"top\": \"5%\",\n",
       "        \"textStyle\": {\n",
       "            \"color\": \"#DC143C\"\n",
       "        }\n",
       "    },\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"piecewise\",\n",
       "        \"min\": 0,\n",
       "        \"max\": 1,\n",
       "        \"text\": [\n",
       "            \"\\u79bb\\u7ed3\\u7387\",\n",
       "            \"\"\n",
       "        ],\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"#50a3ba\",\n",
       "                \"#eac763\",\n",
       "                \"#d94e5d\"\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"seriesIndex\": 0,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"10%\",\n",
       "        \"top\": \"70%\",\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 14,\n",
       "        \"borderWidth\": 0,\n",
       "        \"pieces\": [\n",
       "            {\n",
       "                \"max\": 1.0,\n",
       "                \"min\": 0.8,\n",
       "                \"label\": \"0.8-1.0\",\n",
       "                \"color\": \"#990000\"\n",
       "            },\n",
       "            {\n",
       "                \"max\": 0.8,\n",
       "                \"min\": 0.6,\n",
       "                \"label\": \"0.6-0.8\",\n",
       "                \"color\": \"#CD5C5C\"\n",
       "            },\n",
       "            {\n",
       "                \"max\": 0.6,\n",
       "                \"min\": 0.4,\n",
       "                \"label\": \"0.4-0.6\",\n",
       "                \"color\": \"#F08080\"\n",
       "            },\n",
       "            {\n",
       "                \"max\": 0.4,\n",
       "                \"min\": 0.2,\n",
       "                \"label\": \"0.2-0.4\",\n",
       "                \"color\": \"#FFCC99\"\n",
       "            },\n",
       "            {\n",
       "                \"max\": 0.2,\n",
       "                \"min\": 0.0,\n",
       "                \"label\": \"0.0-0.2\",\n",
       "                \"color\": \"#FFE4E1\"\n",
       "            }\n",
       "        ]\n",
       "    }\n",
       "};\n",
       "                chart_2eed60316aa9458db751deebf883c521.setOption(option_2eed60316aa9458db751deebf883c521);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1c49d7b2108>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 线性渐变\n",
    "color_js = \"\"\"new echarts.graphic.LinearGradient(0, 0, 1, 0,\n",
    "    [{offset: 0, color: '#009ad6'}, {offset: 1, color: '#ed1941'}], false)\"\"\"\n",
    "df_tmp = df_tmp.replace('省', '', regex=True).replace('市', '', regex=True).replace('自治区', '', regex=True).replace('壮族', '', regex=True).replace('维吾尔', '', regex=True).replace('回族', '', regex=True)\n",
    "map_chart = Map(init_opts=opts.InitOpts(theme='light',\n",
    "                                        width='800px',\n",
    "                                        height='600px'))\n",
    "map_chart.add('离婚/结婚',\n",
    "              [list(z) for z in zip(df_tmp['地区'].values.tolist(), df_tmp['离结率'].values.tolist())],\n",
    "              maptype='china',\n",
    "              is_map_symbol_show=False,\n",
    "              itemstyle_opts={\n",
    "                  'normal': {\n",
    "                      'shadowColor': 'rgba(0, 0, 0, .5)',  # 阴影颜色\n",
    "                      'shadowBlur': 5,  # 阴影大小\n",
    "                      'shadowOffsetY': 0,  # Y轴方向阴影偏移\n",
    "                      'shadowOffsetX': 0,  # x轴方向阴影偏移\n",
    "                      'borderColor': '#fff'\n",
    "                  }\n",
    "              }\n",
    "              )\n",
    "map_chart.set_global_opts(\n",
    "    visualmap_opts=opts.VisualMapOpts(\n",
    "        is_show=True,\n",
    "        is_piecewise=True,\n",
    "        min_ = 0,\n",
    "        max_ = 1,\n",
    "        split_number = 5,\n",
    "        series_index=0,\n",
    "        pos_top='70%',\n",
    "        pos_left='10%',\n",
    "        range_text=['离结率', ''],\n",
    "        pieces=[\n",
    "            {'max':1.0, 'min':0.8, 'label':'0.8-1.0', 'color': '#990000'},\n",
    "            {'max':0.8, 'min':0.6, 'label':'0.6-0.8', 'color': '#CD5C5C'},\n",
    "            {'max':0.6, 'min':0.4, 'label':'0.4-0.6', 'color': '#F08080'},\n",
    "            {'max':0.4, 'min':0.2, 'label':'0.2-0.4', 'color': '#FFCC99'},\n",
    "            {'max':0.2, 'min':0.0, 'label':'0.0-0.2', 'color': '#FFE4E1'},\n",
    "           ],\n",
    "    ),\n",
    "    legend_opts=opts.LegendOpts(is_show=False),\n",
    "    tooltip_opts=opts.TooltipOpts(\n",
    "        is_show=True,\n",
    "        trigger='item',\n",
    "        formatter='{b}:{c}'\n",
    "    ),\n",
    "    title_opts=dict(\n",
    "        text='2019年各地区离结率',\n",
    "        left='center',\n",
    "        top='5%',\n",
    "        textStyle=dict(\n",
    "            color='#DC143C'))\n",
    ")\n",
    "map_chart.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f8ac9db1",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "## 历年全国结婚离婚登记趋势"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "61d3d2c4",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "df_marry.loc[\"总计\"] =df_marry.apply(lambda x:x.sum()) \n",
    "df_divorce.loc[\"总计\"] =df_divorce.apply(lambda x:x.sum()) \n",
    "df_marry.loc['总计','地区'] = '全国'\n",
    "df_divorce.loc['总计','地区'] = '全国'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "b027349a",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>地区</th>\n",
       "      <th>2019年</th>\n",
       "      <th>2018年</th>\n",
       "      <th>2017年</th>\n",
       "      <th>2016年</th>\n",
       "      <th>2015年</th>\n",
       "      <th>2014年</th>\n",
       "      <th>2013年</th>\n",
       "      <th>2012年</th>\n",
       "      <th>2011年</th>\n",
       "      <th>2010年</th>\n",
       "      <th>2009年</th>\n",
       "      <th>2008年</th>\n",
       "      <th>2007年</th>\n",
       "      <th>2006年</th>\n",
       "      <th>2005年</th>\n",
       "      <th>2004年</th>\n",
       "      <th>2003年</th>\n",
       "      <th>2002年</th>\n",
       "      <th>2001年</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>总计</th>\n",
       "      <td>全国</td>\n",
       "      <td>927.33</td>\n",
       "      <td>1013.94</td>\n",
       "      <td>1063.1</td>\n",
       "      <td>1142.84</td>\n",
       "      <td>1224.71</td>\n",
       "      <td>1306.72</td>\n",
       "      <td>1346.93</td>\n",
       "      <td>1323.58</td>\n",
       "      <td>1302.35</td>\n",
       "      <td>1241.2</td>\n",
       "      <td>1212.43</td>\n",
       "      <td>1098.3</td>\n",
       "      <td>991.38</td>\n",
       "      <td>944.9</td>\n",
       "      <td>823.1</td>\n",
       "      <td>867.21</td>\n",
       "      <td>810.64</td>\n",
       "      <td>786.1</td>\n",
       "      <td>804.95</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    地区   2019年    2018年   2017年    2016年    2015年    2014年    2013年    2012年  \\\n",
       "总计  全国  927.33  1013.94  1063.1  1142.84  1224.71  1306.72  1346.93  1323.58   \n",
       "\n",
       "      2011年   2010年    2009年   2008年   2007年  2006年  2005年   2004年   2003年  \\\n",
       "总计  1302.35  1241.2  1212.43  1098.3  991.38  944.9  823.1  867.21  810.64   \n",
       "\n",
       "    2002年   2001年  \n",
       "总计  786.1  804.95  "
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_marry[df_marry['地区'] == '全国']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "72943bb8",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>地区</th>\n",
       "      <th>2019年</th>\n",
       "      <th>2018年</th>\n",
       "      <th>2017年</th>\n",
       "      <th>2016年</th>\n",
       "      <th>2015年</th>\n",
       "      <th>2014年</th>\n",
       "      <th>2013年</th>\n",
       "      <th>2012年</th>\n",
       "      <th>2011年</th>\n",
       "      <th>2010年</th>\n",
       "      <th>2009年</th>\n",
       "      <th>2008年</th>\n",
       "      <th>2007年</th>\n",
       "      <th>2006年</th>\n",
       "      <th>2005年</th>\n",
       "      <th>2004年</th>\n",
       "      <th>2003年</th>\n",
       "      <th>2002年</th>\n",
       "      <th>2001年</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>总计</th>\n",
       "      <td>全国</td>\n",
       "      <td>470.09</td>\n",
       "      <td>446.07</td>\n",
       "      <td>437.35</td>\n",
       "      <td>415.81</td>\n",
       "      <td>384.14</td>\n",
       "      <td>363.65</td>\n",
       "      <td>350.02</td>\n",
       "      <td>310.42</td>\n",
       "      <td>287.38</td>\n",
       "      <td>267.8</td>\n",
       "      <td>246.78</td>\n",
       "      <td>226.89</td>\n",
       "      <td>209.83</td>\n",
       "      <td>191.0</td>\n",
       "      <td>178.4</td>\n",
       "      <td>166.4</td>\n",
       "      <td>132.4</td>\n",
       "      <td>117.6</td>\n",
       "      <td>125.07</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    地区   2019年   2018年   2017年   2016年   2015年   2014年   2013年   2012年  \\\n",
       "总计  全国  470.09  446.07  437.35  415.81  384.14  363.65  350.02  310.42   \n",
       "\n",
       "     2011年  2010年   2009年   2008年   2007年  2006年  2005年  2004年  2003年  2002年  \\\n",
       "总计  287.38  267.8  246.78  226.89  209.83  191.0  178.4  166.4  132.4  117.6   \n",
       "\n",
       "     2001年  \n",
       "总计  125.07  "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_divorce[df_marry['地区'] == '全国']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "ff2da41f",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"7d02aa3b3f1641779e6533e2886e4e62\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_7d02aa3b3f1641779e6533e2886e4e62 = echarts.init(\n",
       "                    document.getElementById('7d02aa3b3f1641779e6533e2886e4e62'), 'white', {renderer: 'canvas'});\n",
       "                var option_7d02aa3b3f1641779e6533e2886e4e62 = {\n",
       "    \"backgroundColor\": new echarts.graphic.RadialGradient(0.3, 0.3, 0.8, [{offset: 0,color: '#FEFEDF'}, {offset: 1,color: '#FEF7FF'}]),\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#ed1941\",\n",
       "        \"#009ad6\",\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u7ed3\\u5a5a\\u767b\\u8bb0\",\n",
       "            \"connectNulls\": false,\n",
       "            \"symbolSize\": 8,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": true,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2001\\u5e74\",\n",
       "                    927.33\n",
       "                ],\n",
       "                [\n",
       "                    \"2002\\u5e74\",\n",
       "                    1013.94\n",
       "                ],\n",
       "                [\n",
       "                    \"2003\\u5e74\",\n",
       "                    1063.1\n",
       "                ],\n",
       "                [\n",
       "                    \"2004\\u5e74\",\n",
       "                    1142.84\n",
       "                ],\n",
       "                [\n",
       "                    \"2005\\u5e74\",\n",
       "                    1224.71\n",
       "                ],\n",
       "                [\n",
       "                    \"2006\\u5e74\",\n",
       "                    1306.72\n",
       "                ],\n",
       "                [\n",
       "                    \"2007\\u5e74\",\n",
       "                    1346.93\n",
       "                ],\n",
       "                [\n",
       "                    \"2008\\u5e74\",\n",
       "                    1323.58\n",
       "                ],\n",
       "                [\n",
       "                    \"2009\\u5e74\",\n",
       "                    1302.35\n",
       "                ],\n",
       "                [\n",
       "                    \"2010\\u5e74\",\n",
       "                    1241.2\n",
       "                ],\n",
       "                [\n",
       "                    \"2011\\u5e74\",\n",
       "                    1212.43\n",
       "                ],\n",
       "                [\n",
       "                    \"2012\\u5e74\",\n",
       "                    1098.3\n",
       "                ],\n",
       "                [\n",
       "                    \"2013\\u5e74\",\n",
       "                    991.38\n",
       "                ],\n",
       "                [\n",
       "                    \"2014\\u5e74\",\n",
       "                    944.9\n",
       "                ],\n",
       "                [\n",
       "                    \"2015\\u5e74\",\n",
       "                    823.1\n",
       "                ],\n",
       "                [\n",
       "                    \"2016\\u5e74\",\n",
       "                    867.21\n",
       "                ],\n",
       "                [\n",
       "                    \"2017\\u5e74\",\n",
       "                    810.64\n",
       "                ],\n",
       "                [\n",
       "                    \"2018\\u5e74\",\n",
       "                    786.1\n",
       "                ],\n",
       "                [\n",
       "                    \"2019\\u5e74\",\n",
       "                    804.95\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"normal\": {\n",
       "                    \"width\": 4,\n",
       "                    \"shadowColor\": \"#696969\",\n",
       "                    \"shadowBlur\": 10,\n",
       "                    \"shadowOffsetY\": 10,\n",
       "                    \"shadowOffsetX\": 10\n",
       "                }\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0.6\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"symbolSize\": [\n",
       "                    65,\n",
       "                    50\n",
       "                ],\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8,\n",
       "                    \"fontSize\": 10\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"min\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"max\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"silent\": false,\n",
       "                \"precision\": 2,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"average\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0,\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u79bb\\u5a5a\\u767b\\u8bb0\",\n",
       "            \"connectNulls\": false,\n",
       "            \"symbolSize\": 8,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": true,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2001\\u5e74\",\n",
       "                    470.09\n",
       "                ],\n",
       "                [\n",
       "                    \"2002\\u5e74\",\n",
       "                    446.07\n",
       "                ],\n",
       "                [\n",
       "                    \"2003\\u5e74\",\n",
       "                    437.35\n",
       "                ],\n",
       "                [\n",
       "                    \"2004\\u5e74\",\n",
       "                    415.81\n",
       "                ],\n",
       "                [\n",
       "                    \"2005\\u5e74\",\n",
       "                    384.14\n",
       "                ],\n",
       "                [\n",
       "                    \"2006\\u5e74\",\n",
       "                    363.65\n",
       "                ],\n",
       "                [\n",
       "                    \"2007\\u5e74\",\n",
       "                    350.02\n",
       "                ],\n",
       "                [\n",
       "                    \"2008\\u5e74\",\n",
       "                    310.42\n",
       "                ],\n",
       "                [\n",
       "                    \"2009\\u5e74\",\n",
       "                    287.38\n",
       "                ],\n",
       "                [\n",
       "                    \"2010\\u5e74\",\n",
       "                    267.8\n",
       "                ],\n",
       "                [\n",
       "                    \"2011\\u5e74\",\n",
       "                    246.78\n",
       "                ],\n",
       "                [\n",
       "                    \"2012\\u5e74\",\n",
       "                    226.89\n",
       "                ],\n",
       "                [\n",
       "                    \"2013\\u5e74\",\n",
       "                    209.83\n",
       "                ],\n",
       "                [\n",
       "                    \"2014\\u5e74\",\n",
       "                    191.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2015\\u5e74\",\n",
       "                    178.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2016\\u5e74\",\n",
       "                    166.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2017\\u5e74\",\n",
       "                    132.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2018\\u5e74\",\n",
       "                    117.6\n",
       "                ],\n",
       "                [\n",
       "                    \"2019\\u5e74\",\n",
       "                    125.07\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"normal\": {\n",
       "                    \"width\": 4,\n",
       "                    \"shadowColor\": \"#696969\",\n",
       "                    \"shadowBlur\": 10,\n",
       "                    \"shadowOffsetY\": 10,\n",
       "                    \"shadowOffsetX\": 10\n",
       "                }\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0.6\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"symbolSize\": [\n",
       "                    65,\n",
       "                    50\n",
       "                ],\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8,\n",
       "                    \"fontSize\": 10\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"min\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"max\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"silent\": false,\n",
       "                \"precision\": 2,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"average\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0,\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u7ed3\\u5a5a\\u767b\\u8bb0\",\n",
       "                \"\\u79bb\\u5a5a\\u767b\\u8bb0\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u7ed3\\u5a5a\\u767b\\u8bb0\": true,\n",
       "                \"\\u79bb\\u5a5a\\u767b\\u8bb0\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"right\": \"1%\",\n",
       "            \"top\": \"2%\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14,\n",
       "            \"icon\": \"roundRect\"\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"axis\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"type\": \"category\",\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"axisLine\": {\n",
       "                \"show\": true,\n",
       "                \"onZero\": true,\n",
       "                \"onZeroAxisIndex\": 0,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 2,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\",\n",
       "                    \"color\": \"#787586\"\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"rotate\": 45,\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"boundaryGap\": true,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": null\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": true,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"nameTextStyle\": {\n",
       "                \"color\": \"#474554\",\n",
       "                \"fontWeight\": \"bold\",\n",
       "                \"fontSize\": 12\n",
       "            },\n",
       "            \"gridIndex\": 0,\n",
       "            \"axisLine\": {\n",
       "                \"show\": false,\n",
       "                \"onZero\": true,\n",
       "                \"onZeroAxisIndex\": 0,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 2,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\",\n",
       "                    \"color\": \"#787586\"\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\": \"{value} /\\u4e07\\u5bf9\"\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"dashed\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5386\\u5e74\\u5168\\u56fd\\u7ed3/\\u79bb\\u5a5a\\u767b\\u8bb0\\u8d8b\\u52bf\",\n",
       "            \"top\": \"2%\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textStyle\": {\n",
       "                \"color\": \"#474554\",\n",
       "                \"fontSize\": 20\n",
       "            }\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_7d02aa3b3f1641779e6533e2886e4e62.setOption(option_7d02aa3b3f1641779e6533e2886e4e62);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1c49d6879c8>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 背景色\n",
    "background_color_js = \"\"\"\n",
    "new echarts.graphic.RadialGradient(0.3, 0.3, 0.8, [{offset: 0,color: '#FEFEDF'}, \n",
    "{offset: 1,color: '#FEF7FF'}])\n",
    "\"\"\"\n",
    " \n",
    "# 线条样式\n",
    "linestyle_dic = { 'normal': {\n",
    "                    'width': 4,  \n",
    "                    'shadowColor': '#696969', \n",
    "                    'shadowBlur': 10,  \n",
    "                    'shadowOffsetY': 10,  \n",
    "                    'shadowOffsetX': 10,  \n",
    "                    }\n",
    "                }\n",
    "l1 = (\n",
    "    Line(init_opts=opts.InitOpts(bg_color=JsCode(background_color_js)))\n",
    "    .add_xaxis(xaxis_data=df_divorce.columns[1:][::-1])\n",
    "    .add_yaxis(\n",
    "        series_name=\"结婚登记\",\n",
    "        y_axis=[round(i,2) for i in df_marry.loc[\"总计\"].values.tolist()[1:]],\n",
    "        symbol_size=8,\n",
    "        is_smooth=True,\n",
    "        color=\"#009ad6\",\n",
    "    )\n",
    "    .add_yaxis(\n",
    "        series_name=\"离婚登记\",\n",
    "        y_axis=[round(i,2) for i in df_divorce.loc[\"总计\"].values.tolist()[1:]],\n",
    "        symbol_size=8,\n",
    "        is_smooth=True,        \n",
    "        color=\"#ed1941\",\n",
    "    )\n",
    "    # 系列配置项\n",
    "    .set_series_opts(linestyle_opts=linestyle_dic,\n",
    "                     areastyle_opts=opts.AreaStyleOpts(opacity=0.6),\n",
    "                     label_opts=opts.LabelOpts(is_show=False),\n",
    "                     markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_=\"average\")]),\n",
    "                     markpoint_opts=opts.MarkPointOpts(\n",
    "                        data=[opts.MarkPointItem(type_=\"max\"), opts.MarkPointItem(type_=\"min\")],\n",
    "                        symbol_size=[65, 50],\n",
    "                        label_opts=opts.LabelOpts(position=\"inside\", color=\"#fff\", font_size=10)\n",
    "                        ),\n",
    "                    )\n",
    "    # 通用配置项\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(\n",
    "                title='历年全国结/离婚登记趋势',\n",
    "                pos_top='2%',\n",
    "                title_textstyle_opts=opts.TextStyleOpts(color='#474554', font_size=20)),\n",
    "        tooltip_opts=opts.TooltipOpts(trigger=\"axis\"),\n",
    "        xaxis_opts=opts.AxisOpts(name=\"\",type_=\"category\", \n",
    "                         boundary_gap=True,\n",
    "                         axisline_opts=opts.AxisLineOpts(is_show=True,\n",
    "                                                         linestyle_opts=opts.LineStyleOpts(width=2, color='#787586')),\n",
    "                         axislabel_opts=opts.LabelOpts(rotate=45)),\n",
    "        yaxis_opts=opts.AxisOpts(\n",
    "                axislabel_opts=opts.LabelOpts(formatter=\"{value} /万对\"),\n",
    "                is_scale=True,\n",
    "                name_textstyle_opts=opts.TextStyleOpts(font_size=12,font_weight='bold',color='#474554'),\n",
    "                splitline_opts=opts.SplitLineOpts(is_show=True, \n",
    "                                                  linestyle_opts=opts.LineStyleOpts(type_='dashed')),\n",
    "                axisline_opts=opts.AxisLineOpts(is_show=False,\n",
    "                                        linestyle_opts=opts.LineStyleOpts(width=2, color='#787586'))\n",
    "            ),\n",
    "        # 图例样式\n",
    "        legend_opts=opts.LegendOpts(is_show=True, pos_right='1%', pos_top='2%',legend_icon='roundRect'),\n",
    "    )\n",
    ")\n",
    "l1.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "758794ca",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# 总结\n",
    "**从我们统计分析的数据可以得知，我国各省份结婚总对数从2001年至2013年保持上升趋势达到峰值1346.93对，从2014年开始减少，而离婚率从2001年以来持续上升  \n",
    "1.结婚登记数量前五地区：河南、广东、四川、江苏、安徽  \n",
    "2.离婚登记数量前五地区：河南、四川、江苏、山东、河北  \n",
    "3.全国结婚登记数量从2007年开始出现持续下降趋势  \n",
    "4.北方地区离结率较南方地区高出不少**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6be28b3f",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "67897efb",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3bbac1dd",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b86906d4",
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "303.837px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}